package com.bq.server.base;


import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.bq.server.enumeration.YesOrNoEnum;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.SuperBuilder;
import org.apache.ibatis.type.EnumTypeHandler;

import java.time.LocalDateTime;

/**
 * 实体基类，定义了公共属性
 *
 * @author: ChenSH
 */
@Data
@SuperBuilder
@EqualsAndHashCode(callSuper = true)
public abstract class BaseEntity<T extends BaseEntity<T>> extends UpdatedEntity<T> {

    /**
     * 是否删除 0 否  1 是
     */
    @TableLogic
    @TableField(typeHandler = EnumTypeHandler.class)
    private YesOrNoEnum deleted;

    public BaseEntity(Long id, String createdBy, LocalDateTime createdDate, String updatedBy, LocalDateTime updatedDate, YesOrNoEnum deleted) {
        super(id, createdBy, createdDate, updatedBy, updatedDate);
        this.deleted = deleted;
    }

    public BaseEntity() {
    }
}
